home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5622 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  737 b 

  1. Path: csus.edu!news
  2. From: wleong@sfsu.edu (Jerry Leong)
  3. Newsgroups: comp.lang.c
  4. Subject: Optimization Q: for( i=0; i<SIZE/2; i++) ??
  5. Date: Fri, 16 Feb 1996 09:40:41 GMT
  6. Organization: California State University Sacramento
  7. Message-ID: <4g1j9n$ooe@news.csus.edu>
  8. NNTP-Posting-Host: wleong@pluto.sfsu.edu
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11.  
  12. This question has been bothering me for quite a while now.
  13.  
  14. If I have the following for loop,
  15.         for( i=0; i< SIZE/2 ; i++).....
  16. Will the code execute faster if I precompute SIZE/2 before hand and
  17. do this
  18.       k = SIZE/2;
  19.        for(i=0; i<k ; i++).....
  20.  
  21. How does this work? I mean, would SIZE/2 get computed everytime during
  22. the for loop, or it simply caculated once?
  23.  
  24. Thanx in advance!
  25.  
  26.